package com.carbon.controller;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.carbon.common.annotation.Log;
import com.carbon.common.config.RuoYiConfig;
import com.carbon.common.core.domain.AjaxResult;
import com.carbon.common.core.redis.RedisCache;
import com.carbon.common.enums.BusinessType;
import com.carbon.common.utils.SecurityUtils;
import com.carbon.common.utils.file.FileUploadUtils;
import com.carbon.common.utils.file.FileUtils;
import com.carbon.common.utils.poi.ExcelUtil;
import com.carbon.common.utils.sign.Base64;
import com.carbon.domain.Firm;
import com.carbon.domain.Mark;
import com.carbon.domain.MarkFirm;
import com.carbon.domain.Product;
import com.carbon.dto.FirmDto;
import com.carbon.dto.GoodDto;
import com.carbon.dto.MarkDto;
import com.carbon.framework.config.ServerConfig;
import com.carbon.service.FirmService;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

import com.carbon.service.MarkFirmService;
import com.carbon.service.MarkService;
import com.carbon.utils.OrderIdUtil;
import com.carbon.vo.*;
import com.tencentcloudapi.ocr.v20181119.OcrClient;
import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.ocr.v20181119.models.*;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * 公司投标信息(Firm)表控制层
 *
 * @author WangFK
 * @since 2023-09-11 16:46:00
 */
@RestController
@Slf4j
@RequestMapping("/wms/firm")
public class FirmController {
    /**
     * 服务对象
     */
    @Resource
    private FirmService firmService;
    @Resource
    private RedisCache redisCache;
    @Resource
    private ServerConfig serverConfig;
    @Resource
    private MarkFirmService markFirmService;
    @Resource
    private MarkService markService;
    String SecretId = "AKIDh040nR5hCVfpwAIHA0GXkxX6b5UijV5U";
    String SecretKey = "ILBm8Fc7cx50hAUcdeAcx9JWdeYJtIWe";


    /**
     * 根据分页条件导出
     * @param response
     * @param params
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, SearchParams params)
    {
        AjaxResult list1 = list(params);
        List<Firm> rows = JSONUtil.toList(JSONUtil.toJsonStr(list1.get("rows")), Firm.class);
        ExcelUtil<Firm> util = new ExcelUtil<Firm>(Firm.class);
        util.exportExcel(response, rows, "投标资料");
    }
    /**
     * 我的标的 页面显示
     * @param params
     * @return
     */
    @GetMapping("/listMarkFirm")
    public AjaxResult listMarkFirm(SearchParams params) {
        String search = params.getSearch();
        String dateTime = params.getDateTime();
        Page<Mark> markPage = new Page<>(params.getPageNum(), params.getPageSize());
        LambdaUpdateWrapper<Mark> lqw = new LambdaUpdateWrapper<Mark>()
                .eq(Mark::getMarkStatus, "0");
        if (ObjectUtil.isNotEmpty(search)) {
            lqw.like(ObjectUtil.isNotEmpty(params.getSearch()), Mark::getMarkName, params.getSearch());
        }
        if (ObjectUtil.isNotEmpty(dateTime)) {
            lqw.like(ObjectUtil.isNotEmpty(dateTime), Mark::getCreateTime, dateTime).or()
                    .like(ObjectUtil.isNotEmpty(dateTime), Mark::getMarkEnd, dateTime);
        }
        markPage = markService.page(markPage, lqw);
        List<Mark> records = markPage.getRecords();
        if (ObjectUtil.isEmpty(records)){
            return AjaxResult.success();
        }
        List<MarkDto> markDtos = BeanUtil.copyToList(records, MarkDto.class);
        markDtos.stream().forEach(item->{
            // 今天时间
            DateTime date1 = DateUtil.parse(DateUtil.today());
            // 结束时间
            DateTime date2 = DateUtil.parse(item.getMarkEnd());
            if (DateUtil.between(date1, date2, DateUnit.DAY)<0){
                // 自动下架
                LambdaUpdateWrapper<Mark> set = new LambdaUpdateWrapper<Mark>()
                        .eq(Mark::getId, item.getId())
                        .set(Mark::getMarkStatus, "1");
                markService.update(set);
                item.setMarkStatus("1");
            }
            LambdaUpdateWrapper<MarkFirm> lqw1 = new LambdaUpdateWrapper<MarkFirm>()
                    .eq(MarkFirm::getMarkId, item.getId())
                    .ne(MarkFirm::getFirmStatus,"1")
                    .eq(MarkFirm::getUserId, SecurityUtils.getUserId());
            MarkFirm one = markFirmService.getOne(lqw1);
            if (ObjectUtil.isNotEmpty(one)){
                item.setFirmStatus(one.getFirmStatus());
                Firm byId = firmService.getById(one.getFirmId());
                if (byId!=null){
                    item.setFirm(byId);
                }
            }
        });
        // 清洗数据 排除下架
        List<MarkDto> collect = markDtos.stream().filter(item -> {
            if ("1".equalsIgnoreCase(item.getMarkStatus())) {
                return false;
            }
            return true;
        }).distinct().collect(Collectors.toList());
        return AjaxResult.success()
                .put("rows",collect)
                .put("total",collect.size());
    }

    /**
     * 修改公司状态
     *
     * @param id
     * @param status
     * @return
     */
    @PutMapping("/changeFirmStatus")
    public AjaxResult changeFirmStatus(Integer id, String status) {
        LambdaUpdateWrapper<Firm> lqw = new LambdaUpdateWrapper<Firm>()
                .eq(Firm::getId, id)
                .set(Firm::getStatus, status);
        return firmService.update(lqw) ? AjaxResult.success() : AjaxResult.error();

    }

    /**
     * 通用图片识别 上传
     *
     * @param file
     * @return
     * @throws Exception
     */
    @PostMapping("/GeneralBasicOCR")
    public AjaxResult uploadGeneralBasicOCR(MultipartFile file) throws Exception {
        try {
            Credential cred = new Credential(SecretId, SecretKey);
            OcrClient client = new OcrClient(cred, "ap-beijing");
            String encode = Base64.encode(file.getBytes());
            GeneralBasicOCRRequest req = new GeneralBasicOCRRequest();
            req.setImageBase64(encode);
            // 返回的resp是一个GeneralBasicOCRResponse的实例，与请求对象对应
            GeneralBasicOCRResponse resp = client.GeneralBasicOCR(req);
            String vo = GeneralBasicOCRResponse.toJsonString(resp);
            GenralBasicOCRVO bean = JSONUtil.toBean(vo, GenralBasicOCRVO.class);

            // 输出json格式的字符串回包
            AjaxResult ajax = getUploadFile(file);
            ajax.put("GenralBasicOCRVO", bean);
            return ajax;
        } catch (Exception e) {
            return AjaxResult.error(e.getMessage());
        }
    }

    /**
     * 营业执照识别 上传
     *
     * @param file
     * @return
     * @throws Exception
     */
    @PostMapping("/BizLicenseOCR")
    public AjaxResult uploadBizLicenseOCR(MultipartFile file) throws Exception {
        try {
            Credential cred = new Credential(SecretId, SecretKey);
            OcrClient client = new OcrClient(cred, "ap-beijing");
            String encode = Base64.encode(file.getBytes());
            // 返回的resp是一个IDCardOCRResponse的实例，与请求对象对应
            BizLicenseOCRRequest req = new BizLicenseOCRRequest();
            req.setImageBase64(encode);
            // 返回的resp是一个BizLicenseOCRResponse的实例，与请求对象对应
            BizLicenseOCRResponse resp = client.BizLicenseOCR(req);
            // 输出json格式的字符串回包
            AjaxResult ajax = getUploadFile(file);
            ajax.put("BizLicenseOCRVO", JSONUtil.toBean(BizLicenseOCRResponse.toJsonString(resp), BizLicenseOCRVO.class));
            return ajax;
        } catch (Exception e) {
            return AjaxResult.error(e.getMessage());
        }
    }

    /**
     * 银行卡识别 上传
     *
     * @param file
     * @return
     * @throws Exception
     */
    @PostMapping("/BankCardOCR")
    public AjaxResult uploadBankCardOCR(MultipartFile file) throws Exception {
        try {
            Credential cred = new Credential(SecretId, SecretKey);
            OcrClient client = new OcrClient(cred, "ap-beijing");
            String encode = Base64.encode(file.getBytes());
            // 返回的resp是一个IDCardOCRResponse的实例，与请求对象对应
            BankCardOCRRequest req = new BankCardOCRRequest();
            req.setImageBase64(encode);
            BankCardOCRResponse resp = client.BankCardOCR(req);
            // 输出json格式的字符串回包
            AjaxResult ajax = getUploadFile(file);
            ajax.put("BankCardOCRVO", JSONUtil.toBean(BankCardOCRResponse.toJsonString(resp), BankCardOCRVO.class));
            return ajax;
        } catch (Exception e) {
            return AjaxResult.error(e.getMessage());
        }
    }

    /**
     * 身份证识别 并上传
     *
     * @param file
     * @return
     * @throws Exception
     */
    @PostMapping("/IDCardOCR")
    public AjaxResult uploadFileIDCardOCR(MultipartFile file) throws Exception {
        try {
            Credential cred = new Credential(SecretId, SecretKey);
            OcrClient client = new OcrClient(cred, "ap-beijing");
            IDCardOCRRequest req = new IDCardOCRRequest();
            String encode = Base64.encode(file.getBytes());
            req.setImageBase64(encode);
            req.setCardSide("FRONT");
            // 返回的resp是一个IDCardOCRResponse的实例，与请求对象对应
            IDCardOCRResponse resp = client.IDCardOCR(req);
            // 输出json格式的字符串回包
            IdCardResultVO vo = JSONUtil.toBean(IDCardOCRResponse.toJsonString(resp), IdCardResultVO.class);
            AjaxResult ajax = getUploadFile(file);
            ajax.put("IdCardResultVO", vo);
            return ajax;
        } catch (Exception e) {
            return AjaxResult.error(e.getMessage());
        }
    }

    private AjaxResult getUploadFile(MultipartFile file) throws IOException {
        // 上传文件路径
        String filePath = RuoYiConfig.getUploadPath();
        // 上传并返回新文件名称
        String fileName = FileUploadUtils.upload(filePath, file);
        String url = serverConfig.getUrl() + fileName;
        AjaxResult ajax = AjaxResult.success();
        ajax.put("url", url);
        ajax.put("fileName", fileName);
        ajax.put("newFileName", FileUtils.getName(fileName));
        ajax.put("originalFilename", file.getOriginalFilename());

        return ajax;
    }

    /**
     * 分页
     *
     * @param params
     * @return
     */
    @GetMapping("/list")
    public AjaxResult list(SearchParams params) {
        Page<Firm> firmPage = new Page<>(params.getPageNum(), params.getPageSize());
        String search = params.getSearch();
        List<String> businessScope = params.getBusinessScope();
        List<String> registerAddress = params.getRegisterAddress();
        String dateTime = params.getDateTime();
        LambdaUpdateWrapper<Firm> lqw = new LambdaUpdateWrapper<Firm>()
                .eq(Firm::getStatus,"0")
                .eq(ObjectUtil.isNotEmpty(params.getFirmNature()), Firm::getFirmNature, params.getFirmNature())
                .eq(ObjectUtil.isNotEmpty(params.getBrandName()), Firm::getBrandName, params.getBrandName())
                .orderByAsc(Firm::getFirmCreate);
        if (ObjectUtil.isNotEmpty(search)) {
            lqw.like(Firm::getFirmName, search).or()
                    .like(Firm::getFirmSip, search).or()
                    .like(Firm::getFirmBy, search).or()
                    .like(Firm::getByIdcard, search).or()
                    .like(Firm::getFirmAddress, search).or()
                    .like(Firm::getBrandAccount, search);
        }
        if (ObjectUtil.isNotEmpty(businessScope)) {
            lqw.eq(Firm::getFirmType, businessScope.get(0))
                    .eq(Firm::getBusinessScope, businessScope.get(1));
        }
        if (ObjectUtil.isNotEmpty(registerAddress)) {
            String s = registerAddress.get(0) + "," + registerAddress.get(1) + "," + registerAddress.get(2);
            lqw.eq(Firm::getRegisterAddress, s);
        }
        if (ObjectUtil.isNotEmpty(dateTime)) {
            lqw.like(Firm::getFirmCreate, dateTime).or()
                    .like(Firm::getUpdateTime, dateTime).or()
                    .like(Firm::getBusinessEnd, dateTime);
        }
        firmPage = firmService.page(firmPage, lqw);
        List<Firm> records = firmPage.getRecords();
        List<FirmDto> firmDtos = BeanUtil.copyToList(records, FirmDto.class);
        LambdaUpdateWrapper<MarkFirm> lqw1 = new LambdaUpdateWrapper<MarkFirm>()
                .ne(MarkFirm::getFirmStatus, "1")
                .orderByAsc(MarkFirm::getFirmStatus);
        List<MarkFirm> list = markFirmService.list(lqw1);

        if (ObjectUtil.isNotEmpty(list)){
            list.stream().forEach(item->{
                for (FirmDto item1 : firmDtos) {
                    if (item.getFirmId().toString().equals(item1.getId().toString())){
                        item1.setMarkId(item.getMarkId());
                        item1.setFirmStatus(item.getFirmStatus());
                        break;
                    }
                }
            });
        }
        // 数据清洗
        List<FirmDto> collect = firmDtos.stream().filter(item -> {
            if (ObjectUtil.isEmpty(item.getMarkId())) {
                return false;
            }
            return true;
        }).collect(Collectors.toList());
        return AjaxResult.success()
                .put("rows", collect)
                .put("total", collect.size());
    }
    @GetMapping("/listMarkUse")
    public AjaxResult listMarkUse(){
        LambdaUpdateWrapper<Mark> lqw = new LambdaUpdateWrapper<Mark>()
                .eq(Mark::getMarkStatus, "0");
        List<Mark> list = markService.list(lqw);
        if (ObjectUtil.isNotEmpty(list)){
            list.stream().forEach(item->{
                // 今天时间
                DateTime date1 = DateUtil.parse(DateUtil.today());
                // 结束时间
                DateTime date2 = DateUtil.parse(item.getMarkEnd());
                if (DateUtil.between(date1, date2, DateUnit.DAY)<0){
                    // 自动下架
                    LambdaUpdateWrapper<Mark> set = new LambdaUpdateWrapper<Mark>()
                            .eq(Mark::getId, item.getId())
                            .set(Mark::getMarkStatus, "1");
                    markService.update(set);

                    LambdaUpdateWrapper<MarkFirm> eq = new LambdaUpdateWrapper<MarkFirm>()
                            .eq(MarkFirm::getMarkId, item.getId())
                            .set(MarkFirm::getFirmStatus,"1");
                    // 修改招标状态
                    markFirmService.update(eq);
                    item.setMarkStatus("1");
                }
            });
            // 所有正常招标信息
            List<Mark> collect = list.stream().filter(item -> {
                if ("1".equalsIgnoreCase(item.getMarkStatus())) {
                    return false;
                }
                return true;
            }).distinct().collect(Collectors.toList());
            return AjaxResult.success(collect);
        }
            return AjaxResult.error();
    }

    /**
     * 获取全国地址
     *
     * @return
     */
    @GetMapping("/getRegisterAddressList")
    public List<AddressVo> getRegisterAddressList() {
        String key = "address:list";
        List<AddressVo> value = redisCache.getCacheList(key);
        if (ObjectUtil.isNotEmpty(value)) {
            return value;
        }
        String url = "https://www.mxnzp.com/api/address/list";
        HashMap<String, Object> params = new HashMap<>();
        params.put("app_id", "idgorwnnojpowkrl");
        params.put("app_secret", "wDKi9GfjUSlvAKb5ftYmV0IoB02PU5ys");

        AjaxResult result = JSONUtil.toBean(JSONUtil.toJsonStr(HttpUtil.get(url, params)), AjaxResult.class);
        List<Map> maps = JSONUtil.toList(result.get("data").toString(), Map.class);
        ArrayList<AddressVo> addresses = new ArrayList<>();
        maps.stream().forEach(item -> {
            AddressVo address = new AddressVo();
            ArrayList<AddressVo> addresses1 = new ArrayList<>();
            String code = item.get("code").toString();
            String name = item.get("name").toString();
            address.setCode(code);
            address.setName(name);
            List<Map> pchilds = Convert.toList(Map.class, item.get("pchilds"));
            pchilds.stream().forEach(item1 -> {
                AddressVo address1 = new AddressVo();
                ArrayList<AddressVo> addresses2 = new ArrayList<>();
                String code1 = item1.get("code").toString();
                String name1 = item1.get("name").toString();
                address1.setCode(code1);
                address1.setName(name1);
                List<Map> cchilds = Convert.toList(Map.class, item1.get("cchilds"));
                cchilds.stream().forEach(item2 -> {
                    AddressVo address2 = new AddressVo();
                    String code2 = item2.get("code").toString();
                    String name2 = item2.get("name").toString();
                    address2.setCode(code2);
                    address2.setName(name2);
                    addresses2.add(address2);
                });
                address1.setChildren(addresses2);
                addresses1.add(address1);
            });
            address.setChildren(addresses1);
            addresses.add(address);
        });
        redisCache.setCacheList(key, addresses);
        redisCache.expire(key, 12, TimeUnit.HOURS);
        return addresses;
    }

    /**
     * 通过主键查询单条数据
     *
     * @param firmId 主键
     * @return 单条数据
     */
    @GetMapping("{firmId}/{markId}")
    public AjaxResult selectOne(@PathVariable Serializable firmId,@PathVariable String markId) {
        Firm byId = firmService.getById(firmId);
        FirmDto firmDto = new FirmDto();
        BeanUtil.copyProperties(byId, firmDto);
        ArrayList<Integer> strings = new ArrayList<>();
        strings.add(Convert.toInt(byId.getFirmType()));
        strings.add(Convert.toInt(byId.getBusinessScope()));
        firmDto.setBusinessScopeList(strings);
        LambdaUpdateWrapper<MarkFirm> lqw = new LambdaUpdateWrapper<MarkFirm>()
                .eq(MarkFirm::getFirmId, firmId)
                .eq(MarkFirm::getMarkId, markId)
                .ne(MarkFirm::getFirmStatus,"1");
        MarkFirm one = markFirmService.getOne(lqw);
        if (ObjectUtil.isNotEmpty(one)){
            Mark byId1 = markService.getById(one.getMarkId());
            firmDto.setMark(byId1);
            firmDto.setMarkId(byId1.getId());
            firmDto.setFirmStatus(one.getFirmStatus());
        }
        return AjaxResult.success(firmDto);
    }

    /**
     * 修改公司投标状态
     * @param firmId
     * @param markId
     * @return
     */
    @PutMapping("/updatMarkStatus")
    public AjaxResult updatMarkStatus(String firmId,String markId,String firmStatus){
        LambdaUpdateWrapper<MarkFirm> set = new LambdaUpdateWrapper<MarkFirm>()
                .eq(MarkFirm::getMarkId, markId)
                .eq(MarkFirm::getFirmId, firmId)
                .set(MarkFirm::getFirmStatus, firmStatus);
        return markFirmService.update(set)?AjaxResult.success():AjaxResult.error();
    }
    /**
     * 新增数据
     *
     * @param map 实体对象
     * @return 新增结果
     */
    @PostMapping
    public AjaxResult insert(@RequestBody Map map) {
        String s = JSONUtil.toJsonStr(map);
        FirmDto firm = JSON.to(FirmDto.class, s);
        Integer markId = firm.getMarkId();
        if (ObjectUtil.isEmpty(markId)){
            return AjaxResult.error("请选择报名项目");
        }
        if (ObjectUtil.isNotEmpty(firm.getId())) {
            Firm byId = firmService.getById(firm.getId());
            if (!byId.getFirmSip().equalsIgnoreCase(firm.getFirmSip())) {
                saveFirMdTO(firm);
                firmService.updateById(firm);
            }
            Firm firm1 = new Firm();
            firm1.setId(byId.getId());
            firm1.setFirmNature(firm.getFirmNature());
            firm1.setFirmType(firm.getFirmType());
            firm1.setFirmTypeName(firm.getFirmTypeName());
            firm1.setBusinessScope(firm.getBusinessScope());
            firm1.setBusinessScopeName(firm.getBusinessScopeName());
            firm1.setFirmRemark(firm.getFirmRemark());
            firmService.updateById(firm1);
        } else {
            saveFirMdTO(firm);
            // 用户id
            firm.setUserId(Convert.toInt(SecurityUtils.getUserId()));
            firm.setFirmId(OrderIdUtil.getOrderId());
            firmService.save(firm);
            MarkFirm markFirm = new MarkFirm();
            markFirm.setFirmId(firm.getId());
            markFirm.setUserId(firm.getUserId());
            markFirm.setMarkId(markId);
            markFirm.setFirmStatus("1");
            markFirmService.save(markFirm);
        }
        return AjaxResult.success().put("firmId",firm.getId());
    }

    private static void saveFirMdTO(FirmDto firm) {
        // 这里不做任何 非空判断
        BizLicenseOCRVO bizLicenseOCRVO = firm.getBizLicenseOCRVO();
        // 公司名
        firm.setFirmName(bizLicenseOCRVO.getName());
        // spi
        firm.setFirmSip(bizLicenseOCRVO.getRegNum());
        // 公司地址
        firm.setRegisterAddress(bizLicenseOCRVO.getAddress());
        // 类型
        firm.setFirmType(firm.getBusinessScopeList().get(0).toString());
        // 成立日期
        firm.setFirmCreate(DateUtil.formatDate(DateUtil.parse(bizLicenseOCRVO.getSetDate())));
        // 法人
        firm.setFirmBy(bizLicenseOCRVO.getPerson());
        // idcard
        IdCardResultVO idCardResultVO = firm.getIdCardResultVO();
        firm.setByIdcard(idCardResultVO.getIdNum());
        // 判断法人和身份证法人是否相同
//        if (!bizLicenseOCRVO.getPerson().equalsIgnoreCase(idCardResultVO.getName())){
//            return AjaxResult.error("请上传法人身份证");
//        }
        // 单位地址
        firm.setFirmAddress(bizLicenseOCRVO.getAddress());
        // 经营范围
        firm.setBusinessScope(firm.getBusinessScopeList().get(1).toString());
        BankCardOCRVO bankCardOCRVO = firm.getBankCardOCRVO();
        // 开户行
        firm.setBrandName(bankCardOCRVO.getBankInfo());
        // 开户账号
        firm.setBrandAccount(bankCardOCRVO.getCardNo());
        GenralBasicOCRVO genralBasicOCRVO = firm.getGenralBasicOCRVO();
        // 开户地址 这里识别卡号调用api才能得到开户地址 不在实现 把卡名称付给开户地址
        // 这里使用 存款信息单 的 开户地址
        List<GenralBasicOCRVO.TextDetections> textDetections = genralBasicOCRVO.getTextDetections();
        firm.setBrandAddress(textDetections.get(5).getDetectedText());
        // 营业执照有效期 一百年有效
        DateTime offset = DateUtil.offset(DateUtil.parse(bizLicenseOCRVO.getSetDate(), "yyyy年MM月dd日"), DateField.YEAR, 100);
        firm.setBusinessEnd(offset);
    }


    /**
     * 删除数据
     *
     * @param idList 主键结合
     * @return 删除结果
     */
    @DeleteMapping("{idList}")
    public AjaxResult delete(@PathVariable String idList) {
        List<String> split = StrUtil.split(idList, ",");
        LambdaUpdateWrapper<Firm> lqw = new LambdaUpdateWrapper<Firm>()
                .in(Firm::getId, split);
        firmService.remove(lqw);
        LambdaUpdateWrapper<MarkFirm> in = new LambdaUpdateWrapper<MarkFirm>()
                .in(MarkFirm::getFirmId, split);
        return  markFirmService.remove(in)? AjaxResult.success() : AjaxResult.error();
    }
}

